<template>
  <view class="container">
    <!-- 头部问候语 -->
    <view class="greeting">
      <text class="greeting-text">{{ getGreeting() }}! {{ getUserDisplayName() }}</text>
      <image class="avatar" :src="userInfo.wechat_avatar || userInfo.avatar_url || '/static/logo.png'"></image>
    </view>

    <!-- 根据用户类型显示不同内容 -->
    <!-- 患者视图 -->
    <view v-if="isPatient">
      <!-- 有测试数据时显示最新报告 + 历史列表 -->
      <view v-if="hasTestData" class="user-list">
        <!-- ✅ 优化：最新评估报告卡片 -->
        <view v-if="latestAssessment" class="latest-assessment-card">
          <!-- 卡片标题 -->
          <view class="card-title-bar">
            <text class="card-title">📊 最新评估</text>
            <view class="progress-badge-large">
              <text class="progress-text">{{ getCompletedCount(latestAssessment) }}/3</text>
            </view>
          </view>
          
          <!-- 时间信息 -->
          <view class="time-info">
            <text class="time-icon">🕐</text>
            <text class="time-text">{{ formatDateTime(latestAssessment.create_time || latestAssessment.assessment_date) }}</text>
          </view>
          
          <!-- 量表结果卡片 - 只显示已完成的，按完成时间排序 -->
          <view class="scales-grid">
            <view v-for="scale in getCompletedScalesSorted(latestAssessment)" 
                  :key="scale.type" 
                  class="scale-card completed">
              <view class="scale-icon">✅</view>
              <text class="scale-title">{{ scale.name }}</text>
              <text class="scale-score">{{ scale.score }}</text>
              <text class="scale-severity" :class="getSeverityClass(scale.type, scale.score)">
                {{ getSeverity(scale.type, scale.score) }}
              </text>
            </view>
          </view>
        </view>
        
        <!-- 筛选区域 -->
        <view v-if="assessmentHistory && assessmentHistory.length > 1" class="filter-section">
          <view class="filter-title">筛选量表类型</view>
          <view class="filter-buttons">
            <button 
              class="filter-btn" 
              :class="{ active: selectedFilter === 'all' }" 
              @tap="selectedFilter = 'all'">
              全部
            </button>
            <button 
              class="filter-btn" 
              :class="{ active: selectedFilter === 'depression' }" 
              @tap="selectedFilter = 'depression'">
              抑郁量表
            </button>
            <button 
              class="filter-btn" 
              :class="{ active: selectedFilter === 'anxiety' }" 
              @tap="selectedFilter = 'anxiety'">
              焦虑量表
            </button>
            <button 
              class="filter-btn" 
              :class="{ active: selectedFilter === 'mania' }" 
              @tap="selectedFilter = 'mania'">
              狂躁量表
            </button>
          </view>
        </view>
        
        <!-- 历史评估列表 -->
        <view v-if="filteredHistory && filteredHistory.length > 0" class="history-section">
          <view class="history-header-wrapper">
            <text class="history-title">全部评估记录</text>
            <text class="history-count">共 {{ filteredHistory.length }} 条</text>
          </view>
          <view v-for="(ass, index) in filteredHistory" :key="ass.assessment_id" 
                class="history-card" 
                :class="{ 'is-latest': index === 0 }">
            <view class="history-header">
              <view class="date-time-wrapper">
                <text class="history-date">{{ formatDate(ass.create_time || ass.assessment_date) }}</text>
                <text class="history-time">{{ formatTime(ass.create_time || ass.assessment_date) }}</text>
                <text v-if="index === 0" class="latest-badge">最新</text>
              </view>
              <!-- 显示已完成的量表数量 -->
              <view class="progress-badge">
                <text class="progress-text">{{ getFilteredCompletedCount(ass) }} 个量表</text>
              </view>
            </view>
            
            <!-- 只显示已完成的量表，按完成时间排序 -->
            <view class="history-body">
              <view v-for="scale in getCompletedScalesSorted(ass)" 
                    :key="scale.type" 
                    class="scale-status-item completed">
                <text class="status-icon">✅</text>
                <view class="scale-info-wrapper">
                  <text class="scale-name">{{ scale.name }}</text>
                  <text v-if="scale.completionTime && scale.completionTime !== ass.create_time" 
                        class="scale-time">{{ formatTime(scale.completionTime) }}</text>
                </view>
                <text class="scale-score">{{ scale.score }}分</text>
                <text class="scale-severity-text" :class="getSeverityClass(scale.type, scale.score)">
                  {{ getSeverity(scale.type, scale.score) }}
                </text>
              </view>
            </view>
          </view>
        </view>
        
        <!-- 如果筛选后完全没有数据 -->
        <view v-if="!latestAssessment && selectedFilter !== 'all'" class="no-filter-result">
          <text class="hint-icon">🔍</text>
          <text class="hint-text">暂无"{{ getFilterName() }}"的评估记录</text>
          <button class="reset-filter-btn" @tap="selectedFilter = 'all'">查看全部</button>
        </view>
      </view>
      
      <!-- 如果没有测试数据，显示提示 -->
      <view v-else class="no-data">
        <text class="no-data-text">您还没有完成任何测试，请先填写量表</text>
        <button class="start-btn" @tap="navigateToFillScale">立即填写</button>
      </view>
    </view>

    <!-- 医生视图 -->
    <view v-else-if="!isPatient">
        <!-- 增强版搜索区域 -->
        <view class="enhanced-search-container">
          <!-- 搜索输入框 -->
          <view class="search-input-wrapper">
            <text class="search-icon">🔍</text>
            <input type="text" class="search-input" placeholder="搜索患者姓名" v-model="searchKeyword" @focus="showSearchOptions = true"/>
            <text class="clear-btn" v-if="searchKeyword" @tap="clearSearch">×</text>
            <button class="search-btn" @tap="performSearch">搜索</button>
          </view>
          
          <!-- 高级搜索选项 -->
          <view v-if="showSearchOptions" class="search-options">
            <!-- 量表类型筛选 -->
            <view class="option-group">
              <text class="option-label">量表类型：</text>
              <view class="option-buttons">
                <button size="mini" :class="{ active: selectedScale === '' }" @tap="selectedScale = ''">全部</button>
                <button size="mini" :class="{ active: selectedScale === '抑郁量表' }" @tap="selectedScale = '抑郁量表'">抑郁量表</button>
                <button size="mini" :class="{ active: selectedScale === '焦虑量表' }" @tap="selectedScale = '焦虑量表'">焦虑量表</button>
                <button size="mini" :class="{ active: selectedScale === '狂躁量表' }" @tap="selectedScale = '狂躁量表'">狂躁量表</button>
              </view>
            </view>
            
            <!-- 完成进度筛选 -->
            <view class="option-group">
              <text class="option-label">完成进度：</text>
              <view class="option-buttons">
                <button size="mini" :class="{ active: selectedProgress === '' }" @tap="selectedProgress = ''">全部</button>
                <button size="mini" :class="{ active: selectedProgress === '全部完成' }" @tap="selectedProgress = '全部完成'">全部完成</button>
                <button size="mini" :class="{ active: selectedProgress === '部分完成' }" @tap="selectedProgress = '部分完成'">部分完成</button>
              </view>
            </view>
          </view>
          
          <!-- 搜索历史 -->
          <view v-if="searchHistory.length > 0 && !showSearchOptions" class="search-history">
            <view class="history-title">
              <text class="history-text">搜索历史</text>
              <text class="clear-history" @tap="clearHistory">清空</text>
            </view>
            <view class="history-tags">
              <text v-for="keyword in searchHistory" :key="keyword" class="history-tag" @tap="selectHistory(keyword)">{{ keyword }}</text>
            </view>
          </view>
        </view>
        
        <!-- 报告统计概览 -->
        <view class="report-stats">
          <view class="stat-item">
            <text class="stat-number">{{ reportStats.totalReports }}</text>
            <text class="stat-label">报告总数</text>
          </view>
          <view class="stat-item">
            <text class="stat-number">{{ reportStats.completedReports }}</text>
            <text class="stat-label">已完成</text>
          </view>
          <view class="stat-item">
            <text class="stat-number">{{ reportStats.pendingReports }}</text>
            <text class="stat-label">待处理</text>
          </view>
        </view>
        
        <!-- 患者列表 -->
      <view class="user-list">
      <!-- 搜索结果列表 -->
      <view v-if="filteredPatients.length > 0">
        <view v-for="patient in filteredPatients" :key="patient.patientUserId" class="user-card-doctor">
          <!-- 患者信息区域（可点击查看评估记录） -->
          <view class="patient-info-section" @tap="viewPatientAssessmentHistory(patient.patientUserId)">
            <view class="patient-avatar">
              <text class="avatar-text">{{ patient.name.charAt(0) }}</text>
            </view>
            <view class="patient-details">
              <view class="user-header">
                <text class="user-name">{{ patient.name }}</text>
                <text class="user-info">{{ patient.gender }} {{ patient.age }}岁</text>
              </view>
              <view class="progress-wrapper">
                <view class="progress-bar">
                  <view class="progress-fill" :style="{ width: getProgressWidth(patient.progress) }"></view>
                </view>
                <text class="user-progress">{{ patient.progress }}</text>
              </view>
              <view class="scale-tags">
                <view v-for="scale in patient.scales" :key="scale" class="scale-tag">{{ scale }}</view>
              </view>
            </view>
          </view>
          
          <!-- 操作按钮区域 -->
          <view class="action-buttons-section">
            <button class="action-btn create-assessment-btn" @tap.stop="createNewAssessmentForPatient(patient.patientUserId)">
              <text class="btn-icon">➕</text>
              <text class="btn-text">新建评估</text>
            </button>
            <button class="action-btn view-history-btn" @tap.stop="viewPatientAssessmentHistory(patient.patientUserId)">
              <text class="btn-icon">📋</text>
              <text class="btn-text">评估记录</text>
            </button>
          </view>
        </view>
      </view>
      
      <!-- 无搜索结果 -->
      <view v-else class="no-result">
        <text class="no-result-icon">🔍</text>
        <text class="no-result-text">未找到匹配的患者</text>
        <button class="add-patient-btn" @tap="goToSearchPatient">
          <text>添加患者</text>
        </button>
      </view>
    </view>
    
  </view>
  </view> 
</template>

<script>
import { getLoginStatus } from '../../utils/auth.js';
import { getBoundPatients, getPatientAssessments } from '../../utils/api/doctor.js';
import { PageStackManager } from '../../utils/pageStack.js';

export default {
  data() {
    return {
      // 移除本地存储的testData，完全基于API数据
      // testData: {
      //   depression: null, // 抑郁量表数据
      //   anxiety: null,    // 焦虑量表数据
      //   mania: null       // 狂躁量表数据
      // },
      userInfo: {},
      isPatient: true, // 用户是否为患者，默认为患者
      searchKeyword: '',
      showSearchOptions: false,
      selectedScale: '',
      selectedProgress: '',
      searchHistory: [],
      searchResults: [],
      patients: [],
      // 历史评估列表（按时间倒序）
      assessmentHistory: [],
      // 患者筛选器
      selectedFilter: 'all', // 'all', 'depression', 'anxiety', 'mania'
      // 报告统计数据
      reportStats: {
        totalReports: 0,
        completedReports: 0,
        pendingReports: 0
      }
    };
  },
  computed: {
      filteredPatients() {
        // 如果没有搜索关键词，返回所有患者
        if (!this.searchKeyword.trim() && !this.selectedScale && !this.selectedProgress) {
          return this.patients;
        }
        
        return this.patients.filter(patient => {
          // 姓名搜索
          const nameMatch = !this.searchKeyword.trim() || 
                            patient.name.toLowerCase().includes(this.searchKeyword.toLowerCase());
          
          // 量表类型筛选
          const scaleMatch = !this.selectedScale || 
                            patient.scales.includes(this.selectedScale);
          
          // 完成进度筛选
          const progressMatch = !this.selectedProgress || 
                               (this.selectedProgress === '全部完成' && patient.progress.includes('3/3')) ||
                               (this.selectedProgress === '部分完成' && !patient.progress.includes('3/3'));
          
          return nameMatch && scaleMatch && progressMatch;
        });
      },
      // 判断是否有任何测试数据（基于API数据）
      hasTestData() {
        return this.assessmentHistory && this.assessmentHistory.length > 0;
      },
      // 根据筛选条件过滤所有记录
      filteredAssessments() {
        if (!this.assessmentHistory || this.assessmentHistory.length === 0) {
          return [];
        }
        
        let filtered = this.assessmentHistory;
        
        // 根据筛选条件过滤
        if (this.selectedFilter !== 'all') {
          filtered = filtered.filter(ass => {
            if (this.selectedFilter === 'depression') {
              return ass.hamd_status === 1;
            } else if (this.selectedFilter === 'anxiety') {
              return ass.hama_status === 1;
            } else if (this.selectedFilter === 'mania') {
              return ass.ymrs_status === 1;
            }
            return false;
          });
        }
        
        return filtered;
      },
      // 获取最新评估数据（用于顶部卡片显示，根据筛选条件动态变化）
      latestAssessment() {
        const filtered = this.filteredAssessments;
        if (filtered.length === 0) {
          return null;
        }
        return filtered[0]; // 筛选后的最新记录
      },
      // 历史记录（显示所有记录）
      filteredHistory() {
        const filtered = this.filteredAssessments;
        if (filtered.length === 0) {
          return [];
        }
        // 返回所有记录，包括最新的
        return filtered;
      }
    },
  onLoad() {
    // 页面加载时执行
    this.loadData();
  },
  onShow() {
    // TabBar 页面切换回来不会触发 onLoad，这里确保每次可见时都刷新数据
    console.log('[查看报告] onShow - 重新加载数据');
    this.loadData();
  },
  methods: {
      // 获取问候语
      getGreeting() {
        const hour = new Date().getHours();
        if (hour < 6) return '凌晨好';
        if (hour < 9) return '早上好';
        if (hour < 12) return '上午好';
        if (hour < 14) return '中午好';
        if (hour < 18) return '下午好';
        if (hour < 22) return '晚上好';
        return '夜深了';
      },

      // 获取用户显示名称
      getUserDisplayName() {
        // 如果是医生，显示"姓氏+医生"
        if (!this.isPatient) {
          const name = this.userInfo.real_name || this.userInfo.wechat_name || this.userInfo.name;
          if (name && name.length > 0) {
            return name.charAt(0) + '医生';
          }
          return '医生';
        }
        
        // 如果是患者，显示真实姓名或微信昵称
        return this.userInfo.real_name || this.userInfo.wechat_name || '用户';
      },

      // 加载数据
      async loadData() {
        // 搜索功能相关代码
        // 获取用户登录状态
        const loginStatus = getLoginStatus();
        this.userInfo = loginStatus.userInfo;
        // 根据用户类型设置isPatient
        this.isPatient = loginStatus.userType === 'patient';
        console.log('=== 用户类型判断调试信息 ===');
        console.log('loginStatus.userType:', loginStatus.userType);
        console.log('this.isPatient:', this.isPatient);
        console.log('this.hasTestData:', this.hasTestData);
        
        // 如果是医生，优先从API获取最新的医生信息
        if (!this.isPatient) {
          try {
            const { getDoctorSelf } = require('../../utils/api/doctor.js');
            const response = await getDoctorSelf();
            console.log('[查看报告] 获取医生信息:', response);
            if (response && response.code === 200 && response.data) {
              this.userInfo = { ...this.userInfo, ...response.data };
              console.log('[查看报告] 更新后的用户信息:', this.userInfo);
            }
          } catch (error) {
            console.warn('[查看报告] 获取医生信息失败:', error);
          }
          
          await this.loadBoundPatients();
          // 加载报告统计数据
          this.loadReportStats();
        }
        
        // 如果是患者，完全从后端API获取数据
        if (this.isPatient) {
          try {
            // 只从后端API获取患者的评估历史
            await this.loadPatientAssessmentHistory();
          } catch (e) {
            console.error('获取患者评估数据失败:', e);
            uni.showToast({
              title: '获取评估数据失败',
              icon: 'none'
            });
          }
        }
      },
      
      // 加载报告统计数据
      loadReportStats() {
        // 基于实际患者数据计算统计
        const totalReports = this.patients.length;
        
        // 统计完成情况：进度为"3/3已完成"的患者数量
        const completedReports = this.patients.filter(p => {
          const progress = p.progress || '0/3已完成';
          return progress.includes('3/3');
        }).length;
        
        // 待处理：有评估但未完成3个量表的患者数量
        const pendingReports = this.patients.filter(p => {
          const progress = p.progress || '0/3已完成';
          return !progress.includes('3/3') && !progress.includes('0/3');
        }).length;
        
        this.reportStats = {
          totalReports: totalReports,
          completedReports: completedReports,
          pendingReports: pendingReports
        };
        
        console.log('医生报告统计（真实数据）:', this.reportStats);
        console.log('  - 患者总数:', totalReports);
        console.log('  - 已完成评估:', completedReports);
        console.log('  - 待处理:', pendingReports);
      },
      
      // 加载绑定的患者列表
      async loadBoundPatients() {
        try {
          console.log('开始加载绑定的患者列表');
          const response = await getBoundPatients();
          console.log('已绑定患者列表:', response);
          
          if (response.code === 200 && response.data && response.data.patients) {
            // 处理患者数据，添加评估进度信息
            this.patients = response.data.patients.map(patient => {
              console.log('处理患者数据:', {
                patient_id: patient.patient_id,
                completed_status: patient.completed_status,
                completed_scales: patient.completed_scales
              });
              
              // 使用后端API返回的进度信息
              return {
                patientUserId: patient.patient_id,
                assessmentId: patient.latest_assessment_id || null,
                name: patient.real_name,
                gender: patient.gender,
                age: patient.age,
                progress: patient.completed_status || '0/3已完成',  // 使用后端计算的进度
                scales: patient.completed_scales || [],  // 使用后端返回的完成量表列表
                phone: patient.phone,
                bindTime: patient.bind_time
              };
            });
            
            console.log('处理后的患者列表:', this.patients);
          } else {
            console.log('没有绑定的患者或API返回错误:', response);
            this.patients = [];
          }
        } catch (error) {
          console.error('加载患者列表失败:', error);
          uni.showToast({
            title: '加载患者列表失败',
            icon: 'none'
          });
          this.patients = [];
        }
      },
      
      // 移除本地存储加载逻辑，完全基于API数据
      // loadPatientDataFromLocal() {
      //   // 已移除，不再使用本地存储
      // },
      
      // 加载患者评估历史
      async loadPatientAssessmentHistory() {
        try {
          console.log('=== 患者评估历史调试信息 ===');
          console.log('this.userInfo:', this.userInfo);
          console.log('this.userInfo.id:', this.userInfo.id);
          console.log('this.userInfo.user_id:', this.userInfo.user_id);
          
          // 获取当前患者的评估历史
          const patientId = this.userInfo.id || this.userInfo.user_id;
          console.log('使用的患者ID:', patientId);
          
          // 显示加载中提示
          uni.showLoading({
            title: '加载中...',
            mask: true
          });
          
          const response = await getPatientAssessments(patientId);
          
          uni.hideLoading();
          
          if (response.code === 200 && response.data && response.data.list) {
            let assessments = response.data.list;
            
            // ✅ 确保按创建时间倒序排列（最新的在最前面）
            assessments.sort((a, b) => {
              const timeA = new Date(a.create_time || a.assessment_date).getTime();
              const timeB = new Date(b.create_time || b.assessment_date).getTime();
              return timeB - timeA; // 倒序：最新的在前
            });
            
            // 保存全部历史用于列表展示
            this.assessmentHistory = assessments;

            console.log('加载到的评估历史（已排序，最新在前）:', this.assessmentHistory);
            console.log('第一条记录时间:', assessments[0]?.create_time);
            console.log('最后一条记录时间:', assessments[assessments.length - 1]?.create_time);
          } else {
            console.log('没有评估历史数据');
            this.assessmentHistory = [];
          }
        } catch (error) {
          uni.hideLoading();
          console.error('加载患者评估历史失败:', error);
          uni.showToast({
            title: '加载失败',
            icon: 'none'
          });
        }
      },
      
      // 获取测试类型名称
      getTestTypeName(type) {
        const typeMap = {
          'depression': '汉密尔顿抑郁量表',
          'anxiety': '汉密尔顿焦虑量表',
          'mania': '杨氏狂躁评定量表'
        };
        // 如果类型不存在或不在映射中，返回默认值
        if (!type || !typeMap[type]) {
          return '未知测试类型';
        }
        return typeMap[type];
      },
      
      // ✅ 新增：计算评估记录中已完成的量表数量
      getCompletedCount(assessment) {
        if (!assessment) return 0;
        let count = 0;
        if (assessment.hamd_status === 1) count++;
        if (assessment.hama_status === 1) count++;
        if (assessment.ymrs_status === 1) count++;
        return count;
      },
      
      // 获取根据筛选条件显示的已完成量表数量
      getFilteredCompletedCount(assessment) {
        if (!assessment) return 0;
        let count = 0;
        if (assessment.hamd_status === 1 && this.shouldShowScale('depression')) count++;
        if (assessment.hama_status === 1 && this.shouldShowScale('anxiety')) count++;
        if (assessment.ymrs_status === 1 && this.shouldShowScale('mania')) count++;
        return count;
      },
      
      // 判断是否应该显示某个量表
      shouldShowScale(scaleType) {
        if (this.selectedFilter === 'all') return true;
        return this.selectedFilter === scaleType;
      },
      
      // 获取筛选器名称
      getFilterName() {
        const filterNames = {
          'depression': '抑郁量表',
          'anxiety': '焦虑量表',
          'mania': '狂躁量表',
          'all': '全部'
        };
        return filterNames[this.selectedFilter] || '全部';
      },
      
      // 获取已完成的量表并按完成时间排序
      getCompletedScalesSorted(assessment) {
        if (!assessment) return [];
        
        const scales = [];
        
        // 收集所有已完成的量表
        if (assessment.hamd_status === 1 && this.shouldShowScale('depression')) {
          scales.push({
            type: 'depression',
            name: '抑郁量表',
            score: assessment.hamd_total,
            completionTime: assessment.hamd_completion_time || assessment.hamd_create_time || assessment.create_time,
            // 如果没有完成时间，使用一个默认排序值
            sortKey: assessment.hamd_completion_time || assessment.hamd_create_time || assessment.create_time || '1900-01-01'
          });
        }
        
        if (assessment.hama_status === 1 && this.shouldShowScale('anxiety')) {
          scales.push({
            type: 'anxiety',
            name: '焦虑量表',
            score: assessment.hama_total,
            completionTime: assessment.hama_completion_time || assessment.hama_create_time || assessment.create_time,
            sortKey: assessment.hama_completion_time || assessment.hama_create_time || assessment.create_time || '1900-01-01'
          });
        }
        
        if (assessment.ymrs_status === 1 && this.shouldShowScale('mania')) {
          scales.push({
            type: 'mania',
            name: '狂躁量表',
            score: assessment.ymrs_total,
            completionTime: assessment.ymrs_completion_time || assessment.ymrs_create_time || assessment.create_time,
            sortKey: assessment.ymrs_completion_time || assessment.ymrs_create_time || assessment.create_time || '1900-01-01'
          });
        }
        
        // 按完成时间排序（最新的在前）
        scales.sort((a, b) => {
          const timeA = new Date(a.sortKey.replace(/-/g, '/')).getTime();
          const timeB = new Date(b.sortKey.replace(/-/g, '/')).getTime();
          return timeB - timeA; // 倒序：最新完成的在前
        });
        
        console.log('量表按完成时间排序:', scales.map(s => ({ name: s.name, time: s.completionTime })));
        
        return scales;
      },
      
      // ✅ 新增：格式化日期时间（精确到秒）
      formatDateTime(dateTimeStr) {
        if (!dateTimeStr) return '';
        try {
          // 处理不同格式的日期时间字符串
          const date = new Date(dateTimeStr.replace(/-/g, '/'));
          const year = date.getFullYear();
          const month = String(date.getMonth() + 1).padStart(2, '0');
          const day = String(date.getDate()).padStart(2, '0');
          const hours = String(date.getHours()).padStart(2, '0');
          const minutes = String(date.getMinutes()).padStart(2, '0');
          const seconds = String(date.getSeconds()).padStart(2, '0');
          return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
        } catch (e) {
          console.error('日期格式化失败:', e);
          return dateTimeStr;
        }
      },
      
      // ✅ 新增：格式化日期（年月日）
      formatDate(dateStr) {
        if (!dateStr) return '';
        try {
          const date = new Date(dateStr.replace(/-/g, '/'));
          const year = date.getFullYear();
          const month = String(date.getMonth() + 1).padStart(2, '0');
          const day = String(date.getDate()).padStart(2, '0');
          return `${year}-${month}-${day}`;
        } catch (e) {
          return dateStr;
        }
      },
      
      // ✅ 新增：格式化时间（时分秒）
      formatTime(dateTimeStr) {
        if (!dateTimeStr) return ''; 
        try {
          const date = new Date(dateTimeStr.replace(/-/g, '/'));
          console.log('formatTime 输入:', dateTimeStr, '解析后:', date);
          const hours = String(date.getHours()).padStart(2, '0');
          const minutes = String(date.getMinutes()).padStart(2, '0');
          const seconds = String(date.getSeconds()).padStart(2, '0');
          const result = `${hours}:${minutes}:${seconds}`;
          console.log('formatTime 输出:', result);
          return result;
        } catch (e) {
          console.error('formatTime 错误:', e);
          return '';
        }
      },
      
      // ✅ 新增：获取严重程度对应的样式类
      getSeverityClass(type, score) {
        const severity = this.getSeverity(type, score);
        if (severity.includes('严重')) return 'severity-severe';
        if (severity.includes('中度')) return 'severity-moderate';
        if (severity.includes('轻度')) return 'severity-mild';
        return 'severity-normal';
      },
      
      // 根据量表类型和分数计算评定结果
      getSeverity(type, score) {
        if (!score && score !== 0) return '暂无评定结果';
        
        switch(type) {
          case 'depression':
            if (score < 8) return '无抑郁症状';
            else if (score < 17) return '轻度抑郁症状';
            else if (score < 24) return '中度抑郁症状';
            else return '严重抑郁症状';
          case 'anxiety':
            if (score < 14) return '无焦虑症状';
            else if (score < 21) return '轻度焦虑症状';
            else if (score < 28) return '中度焦虑症状';
            else return '严重焦虑症状';
          case 'mania':
            if (score < 6) return '无明显躁狂症状';
            else if (score < 12) return '轻度躁狂症状';
            else if (score < 18) return '中度躁狂症状';
            else if (score < 24) return '明显躁狂症状';
            else return '严重躁狂症状';
          default:
            return '暂无评定结果';
        }
      },
      
      // 导航到填写量表页面
      navigateToFillScale() {
        console.log('🚀 navigateToFillScale 被调用');
        // 使用智能跳转系统跳转到首页（TabBar页面）
        console.log('✅ 使用智能跳转系统跳转到首页');
        PageStackManager.smartNavigateWithTabBar('/pages/index/index');
      },
      
      // 执行搜索
      performSearch() {
        // 添加到搜索历史
        if (this.searchKeyword.trim() && !this.searchHistory.includes(this.searchKeyword.trim())) {
          this.searchHistory.unshift(this.searchKeyword.trim());
          // 限制历史记录数量
          if (this.searchHistory.length > 5) {
            this.searchHistory.pop();
          }
        }
        
        // 收起搜索选项
        this.showSearchOptions = false;
      },
      
      // 清除搜索内容
      clearSearch() {
        this.searchKeyword = '';
        this.selectedScale = '';
        this.selectedProgress = '';
      },
      
      // 从历史记录中选择搜索
      selectHistory(keyword) {
        this.searchKeyword = keyword;
        this.performSearch();
      },
      
      // 清空搜索历史
      clearHistory() {
        this.searchHistory = [];
      },
      
      // 导航到患者评估详情页面
      navigateToPatientDetails(patientUserId, assessmentId) {
        console.log('导航到患者详情:', {patientUserId, assessmentId});
        
        // 检查assessmentId是否有效
        if (!assessmentId || assessmentId === null || assessmentId === 'null') {
          uni.showToast({
            title: '该患者暂无评估记录',
            icon: 'none'
          });
          return;
        }
        
        const url = `/pages/patientAssessmentDetails/patientAssessmentDetails?patientUserId=${patientUserId}&assessmentId=${assessmentId}`;
        
        // 使用页面栈管理工具进行安全跳转
        PageStackManager.navigateToDetail(url);
      },
      
      // 为患者创建新评估
      createNewAssessmentForPatient(patientUserId) {
        console.log('为患者创建新评估:', patientUserId);
        
        // 显示量表选择对话框
        uni.showActionSheet({
          itemList: ['抑郁量表 (HAMD17)', '焦虑量表 (HAMA)', '狂躁量表 (YMRS)', '全部量表'],
          success: (res) => {
            const scaleIndex = res.tapIndex;
            let url = '';
            
            switch (scaleIndex) {
              case 0: // 抑郁量表
                url = `/pages/yiYuLiangBiaoStarter/yiYuLiangBiaoStarter?patientId=${patientUserId}`;
                break;
              case 1: // 焦虑量表
                url = `/pages/jiaoLvLiangBiao/jiaoLvLiangBiao?patientId=${patientUserId}`;
                break;
              case 2: // 狂躁量表
                url = `/pages/kuangZaoLiangBiao/kuangZaoLiangBiao?patientId=${patientUserId}`;
                break;
              case 3: // 全部量表（从抑郁量表开始）
                url = `/pages/yiYuLiangBiaoStarter/yiYuLiangBiaoStarter?patientId=${patientUserId}`;
                break;
            }
            
            if (url) {
              console.log('跳转到量表页面:', url);
              PageStackManager.smartNavigateWithTabBar(url);
            }
          },
          fail: (err) => {
            console.log('用户取消选择量表');
          }
        });
      },
      
      // 获取进度条宽度百分比
      getProgressWidth(progressText) {
        if (!progressText) return '0%';
        const match = progressText.match(/(\d+)\/(\d+)/);
        if (match) {
          const completed = parseInt(match[1]);
          const total = parseInt(match[2]);
          return `${(completed / total) * 100}%`;
        }
        return '0%';
      },
      
      // 跳转到添加患者页面
      goToSearchPatient() {
        console.log('跳转到添加患者页面');
        PageStackManager.smartNavigateWithTabBar('/pages/doctor/searchPatient');
      },
      
      // 查看患者的评估历史记录
      viewPatientAssessmentHistory(patientUserId) {
        console.log('查看患者评估历史:', patientUserId);
        
        if (!patientUserId) {
          uni.showToast({
            title: '患者信息不完整',
            icon: 'none'
          });
          return;
        }
        
        // 跳转到患者评估历史列表页面
        const url = `/pages/doctor/patientAssessments?patientId=${patientUserId}`;
        PageStackManager.smartNavigateWithTabBar(url);
      },
      
    }
};
</script>

<style scoped>
.container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: #f5f5f5;
  padding-bottom: 150rpx; /* 添加底部内边距，防止内容被固定导航栏遮挡 */
}

/* 增强版搜索区域样式 */
.enhanced-search-container {
  background-color: #fff;
  margin-bottom: 20rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

/* 报告统计样式 */
.report-stats {
  display: flex;
  background-color: #fff;
  margin: 20rpx;
  padding: 30rpx;
  border-radius: 15rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.1);
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-number {
  display: block;
  font-size: 48rpx;
  font-weight: bold;
  color: #2db5a3;
}

.stat-label {
  display: block;
  font-size: 28rpx;
  color: #666;
  margin-top: 10rpx;
}

/* 搜索输入框样式 */
.search-input-wrapper {
  display: flex;
  align-items: center;
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  border-radius: 50rpx;
  padding: 8rpx 12rpx 8rpx 24rpx;
  height: 88rpx;
  margin: 20rpx 30rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.06),
              0 2rpx 8rpx rgba(0, 0, 0, 0.04);
  border: 2rpx solid rgba(7, 193, 96, 0.12);
  transition: all 0.3s ease;
}

.search-icon {
  font-size: 36rpx;
  margin-right: 16rpx;
  color: #07c160;
  opacity: 0.8;
}

.search-input {
  flex: 1;
  height: 100%;
  font-size: 30rpx;
  background-color: transparent;
  color: #333;
}

.clear-btn {
  font-size: 38rpx;
  color: #bbb;
  padding: 0 12rpx;
  line-height: 1;
  transition: all 0.2s ease;
}

.clear-btn:active {
  color: #999;
  transform: scale(0.9);
}

.search-btn {
  background: linear-gradient(135deg, #07c160 0%, #06ad51 100%);
  color: white;
  border-radius: 40rpx;
  font-size: 28rpx;
  padding: 0 32rpx;
  height: 64rpx;
  line-height: 64rpx;
  margin-left: 10rpx;
  box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.25);
  transition: all 0.3s ease;
  font-weight: 500;
}

.search-btn:active {
  transform: scale(0.95);
  box-shadow: 0 2rpx 8rpx rgba(7, 193, 96, 0.3);
}

/* 搜索选项样式 */
.search-options {
  padding: 20rpx 30rpx 30rpx;
  background-color: #fff;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10rpx);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.option-group {
  margin-bottom: 20rpx;
}

.option-label {
  font-size: 28rpx;
  color: #666;
  margin-bottom: 15rpx;
  display: block;
}

.option-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 15rpx;
}

.option-buttons button {
  background-color: #f5f5f5;
  color: #666;
  font-size: 26rpx;
  padding: 0 20rpx;
  height: 60rpx;
  line-height: 60rpx;
  border-radius: 30rpx;
}

.option-buttons button.active {
  background-color: #07c160;
  color: white;
}

/* 搜索历史样式 */
.search-history {
  padding: 0 30rpx 20rpx;
}

.history-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15rpx;
}

.history-text {
  font-size: 28rpx;
  color: #666;
}

.clear-history {
  font-size: 24rpx;
  color: #999;
}

.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 15rpx;
}

.history-tag {
  background-color: #f5f5f5;
  padding: 8rpx 20rpx;
  border-radius: 15rpx;
  font-size: 26rpx;
  color: #666;
}

/* 无搜索结果样式 */
.no-result {
  text-align: center;
  padding: 120rpx 40rpx;
  background-color: #fff;
  margin: 20rpx 30rpx;
  border-radius: 20rpx;
  box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
}

.no-result-text {
  font-size: 32rpx;
  color: #999;
}

/* 头部问候语 */
.greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 30rpx;
  background-color: #fff;
  margin-bottom: 20rpx;
}
.greeting-text {
  font-size: 36rpx;
  color: #333;
  font-weight: bold;
}
.avatar {
  width: 60rpx;
  height: 60rpx;
  border-radius: 50%;
}

/* 用户列表 */
.user-list {
  flex: 1;
  padding: 0 30rpx;
  overflow-y: auto;
}

  /* 筛选区域样式 */
  .filter-section {
    background: #fff;
    border-radius: 20rpx;
    padding: 24rpx;
    margin-bottom: 20rpx;
    box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
  }
  
  .filter-title {
    font-size: 28rpx;
    color: #333;
    font-weight: 600;
    margin-bottom: 16rpx;
  }
  
  .filter-buttons {
    display: flex;
    gap: 12rpx;
    flex-wrap: wrap;
  }
  
  .filter-btn {
    flex: 1;
    min-width: 150rpx;
    height: 64rpx;
    line-height: 64rpx;
    padding: 0 20rpx;
    background: #f5f7fa;
    border: 2rpx solid transparent;
    border-radius: 32rpx;
    font-size: 26rpx;
    color: #666;
    transition: all 0.3s ease;
  }
  
  .filter-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 4rpx 12rpx rgba(102, 126, 234, 0.3);
    transform: translateY(-2rpx);
  }
  
  .filter-btn::after {
    border: none;
  }

  /* 历史列表样式 */
  .history-section {
    margin-top: 20rpx;
  }
  
  .history-header-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16rpx;
  }
  
  .history-title {
    font-size: 30rpx;
    color: #333;
    font-weight: 600;
  }
  
  .history-count {
    font-size: 24rpx;
    color: #999;
    background: #f5f5f5;
    padding: 4rpx 16rpx;
    border-radius: 20rpx;
  }
  
  .history-card {
    background: linear-gradient(135deg, #fff 0%, #fafbfc 100%);
    border-radius: 20rpx;
    padding: 24rpx;
    margin-bottom: 16rpx;
    box-shadow: 0 2rpx 12rpx rgba(0,0,0,0.06);
    border: 1rpx solid #f0f0f0;
    transition: all 0.3s ease;
  }
  
  /* 最新记录高亮样式 */
  .history-card.is-latest {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2rpx solid #bae6fd;
    box-shadow: 0 4rpx 16rpx rgba(102, 126, 234, 0.15);
  }
  
  .history-card:active {
    transform: translateY(2rpx);
    box-shadow: 0 1rpx 6rpx rgba(0,0,0,0.08);
  }
  
  .history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16rpx;
    padding-bottom: 16rpx;
    border-bottom: 1rpx solid #f0f0f0;
  }
  
  /* ✅ 优化：日期时间显示 */
  .date-time-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6rpx;
  }
  
  .history-date {
    font-size: 30rpx;
    color: #333;
    font-weight: 600;
  }
  
  .history-time {
    font-size: 24rpx;
    color: #999;
  }
  
  /* 最新记录徽章 */
  .latest-badge {
    display: inline-block;
    margin-left: 12rpx;
    padding: 2rpx 6rpx;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 20rpx;
    border-radius: 6rpx;
    font-weight: 600;
    border: 1rpx solid rgba(255, 255, 255, 0.3);
  }
  
  .history-line {
    font-size: 28rpx;
    color: #333;
    line-height: 40rpx;
  }
  
  .history-body {
    display: flex;
    flex-direction: column;
    gap: 8rpx;
  }
  
  /* ✅ 新增：完成进度徽章 */
  .progress-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    padding: 8rpx 20rpx;
    border-radius: 24rpx;
    font-size: 24rpx;
    box-shadow: 0 2rpx 8rpx rgba(102, 126, 234, 0.3);
  }
  .progress-text {
    font-weight: 600;
  }
  
  /* ✅ 新增：量表状态项 */
  .scale-status-item {
    display: flex;
    align-items: center;
    padding: 16rpx;
    margin-bottom: 12rpx;
    background: #f8f9fa;
    border-radius: 12rpx;
    transition: all 0.3s ease;
  }
  
  .scale-status-item:last-child {
    margin-bottom: 0;
  }
  
  .scale-status-item:active {
    background: #e9ecef;
    transform: scale(0.98);
  }
  
  .status-icon {
    font-size: 36rpx;
    margin-right: 16rpx;
  }
  
  .scale-info-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4rpx;
  }
  
  .scale-name {
    font-size: 28rpx;
    color: #333;
    font-weight: 500;
  }
  
  .scale-time {
    font-size: 20rpx;
    color: #999;
    font-style: italic;
  }
  
  .scale-score {
    font-size: 32rpx;
    color: #52c41a;
    font-weight: bold;
    margin-right: 12rpx;
  }
  
  .scale-severity-text {
    font-size: 24rpx;
    padding: 4rpx 12rpx;
    border-radius: 12rpx;
    font-weight: 500;
  }
  
  .scale-hint {
    font-size: 24rpx;
    color: #999;
  }
  
  /* ✅ 已完成状态样式 */
  .scale-status-item.completed {
    opacity: 1;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1rpx solid #bae6fd;
  }
  
  .scale-status-item.completed .scale-name {
    color: #0c4a6e;
  }
  
  /* ✅ 未完成状态样式 */
  .scale-status-item.pending {
    opacity: 0.5;
  }
  .scale-status-item.pending .scale-name {
    color: #999;
  }

/* ✅ 新增：最新评估卡片样式 */
.latest-assessment-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: 24rpx;
  padding: 30rpx;
  margin: 0 0 30rpx 0;
  box-shadow: 0 8rpx 24rpx rgba(102, 126, 234, 0.3);
  border: 2rpx solid rgba(255, 255, 255, 0.3);
}

.card-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20rpx;
}

.card-title {
  font-size: 34rpx;
  font-weight: bold;
  color: #fff;
}

.progress-badge-large {
  background: rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 8rpx 20rpx;
  border-radius: 24rpx;
  font-size: 28rpx;
  backdrop-filter: blur(10rpx);
}

.time-info {
  display: flex;
  align-items: center;
  margin-bottom: 24rpx;
  padding: 16rpx;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 16rpx;
  backdrop-filter: blur(10rpx);
}

.time-icon {
  font-size: 32rpx;
  margin-right: 12rpx;
}

.time-text {
  font-size: 28rpx;
  color: #fff;
  font-weight: 500;
}

/* 量表网格布局 */
.scales-grid {
  display: flex;
  gap: 16rpx;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.scale-card {
  flex: 1;
  min-width: 200rpx;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20rpx;
  padding: 24rpx 16rpx;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: all 0.3s ease;
  box-shadow: 0 4rpx 12rpx rgba(0,0,0,0.08);
}

.scale-card.completed {
  opacity: 1;
  transform: translateY(0);
}

.scale-card.completed:active {
  transform: translateY(-4rpx);
  box-shadow: 0 8rpx 16rpx rgba(0,0,0,0.12);
}

.scale-card.pending {
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.5);
}

.scale-icon {
  font-size: 48rpx;
  margin-bottom: 12rpx;
}

.scale-title {
  font-size: 24rpx;
  color: #666;
  margin-bottom: 12rpx;
  text-align: center;
}

.scale-score {
  font-size: 56rpx;
  font-weight: bold;
  color: #667eea;
  margin-bottom: 8rpx;
}

.scale-severity {
  font-size: 22rpx;
  padding: 6rpx 16rpx;
  border-radius: 16rpx;
  font-weight: 600;
  text-align: center;
}

.severity-normal {
  background: linear-gradient(135deg, #d4fc79 0%, #96e6a1 100%);
  color: #22543d;
}

.severity-mild {
  background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
  color: #744210;
}

.severity-moderate {
  background: linear-gradient(135deg, #fab1a0 0%, #ff7675 100%);
  color: #7c2d12;
}

.severity-severe {
  background: linear-gradient(135deg, #ff7675 0%, #d63031 100%);
  color: #fff;
}

.scale-pending-text {
  font-size: 24rpx;
  color: #999;
  margin-top: 12rpx;
}

/* 用户卡片（旧样式，保留兼容） */
.user-card {
      background-color: #fff;
      border-radius: 20rpx;
      padding: 30rpx;
      margin-bottom: 20rpx;
      box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05);
      transition: transform 0.2s;
    }
    
    .user-card:active {
      transform: scale(0.98);
      background-color: #f9f9f9;
    }

/* 医生视图优化后的患者卡片 */
.user-card-doctor {
  background-color: #fff;
  border-radius: 20rpx;
  margin-bottom: 24rpx;
  box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: all 0.3s ease;
}

.user-card-doctor:active {
  transform: scale(0.98);
}

/* 患者信息区域 */
.patient-info-section {
  display: flex;
  padding: 24rpx;
  border-bottom: 1rpx solid #f0f0f0;
}

/* 患者头像 */
.patient-avatar {
  width: 88rpx;
  height: 88rpx;
  border-radius: 44rpx;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 20rpx;
  flex-shrink: 0;
}

.avatar-text {
  font-size: 36rpx;
  color: #ffffff;
  font-weight: 600;
}

/* 患者详情 */
.patient-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* 进度条包装器 */
.progress-wrapper {
  display: flex;
  align-items: center;
  margin: 12rpx 0;
}

.progress-bar {
  flex: 1;
  height: 10rpx;
  background: #ecf0f1;
  border-radius: 5rpx;
  margin-right: 12rpx;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #88D5CB 0%, #6BB6FF 100%);
  transition: width 0.3s ease;
  border-radius: 5rpx;
}

/* 操作按钮区域 */
.action-buttons-section {
  display: flex;
  padding: 16rpx 24rpx;
  gap: 16rpx;
  background: #fafafa;
}

.action-btn {
  flex: 1;
  height: 72rpx;
  border-radius: 12rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8rpx;
  font-size: 28rpx;
  border: none;
  transition: all 0.3s ease;
  padding: 0;
}

.create-assessment-btn {
  background: linear-gradient(135deg, #88D5CB 0%, #6BB6FF 100%);
  color: #ffffff;
  box-shadow: 0 4rpx 12rpx rgba(136, 213, 203, 0.3);
}

.create-assessment-btn::after {
  border: none;
}

.create-assessment-btn:active {
  opacity: 0.8;
  transform: scale(0.96);
}

.view-history-btn {
  background: #ffffff;
  color: #88D5CB;
  border: 2rpx solid #88D5CB !important;
}

.view-history-btn::after {
  border: none;
}

.view-history-btn:active {
  background: rgba(136, 213, 203, 0.1);
}

.btn-icon {
  font-size: 32rpx;
  line-height: 1;
}

.btn-text {
  font-size: 28rpx;
  font-weight: 500;
  line-height: 1;
}

/* 空状态优化 */
.no-result-icon {
  font-size: 120rpx;
  display: block;
  margin-bottom: 24rpx;
}

.add-patient-btn {
  width: 320rpx;
  height: 80rpx;
  background: linear-gradient(135deg, #88D5CB 0%, #6BB6FF 100%);
  color: #ffffff;
  border-radius: 40rpx;
  font-size: 28rpx;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  margin-top: 40rpx;
  box-shadow: 0 4rpx 16rpx rgba(136, 213, 203, 0.3);
}

.add-patient-btn::after {
  border: none;
}

.add-patient-btn:active {
  opacity: 0.8;
  transform: scale(0.96);
}

.user-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20rpx;
}
.user-name {
  font-size: 36rpx;
  font-weight: 600;
  color: #333;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.user-info {
  font-size: 28rpx;
  color: #666;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}
.user-progress {
  font-size: 28rpx;
  color: #1aad19;
}

/* 测试日期 */
.test-date {
  font-size: 24rpx;
  color: #999;
}

/* 测试结果 */
.test-result {
  margin: 20rpx 0;
  padding: 20rpx;
  background-color: #f8f8f8;
  border-radius: 10rpx;
}

/* 结果项 */
.result-item {
  display: flex;
  align-items: center;
  margin-bottom: 16rpx;
}

.result-item:last-child {
  margin-bottom: 0;
}

/* 结果标签 */
.result-label {
  font-size: 28rpx;
  color: #666;
  width: 180rpx;
}

/* 结果值 */
.result-value {
  font-size: 28rpx;
  color: #333;
  flex: 1;
}

/* 分数样式 */
.result-value.score {
  font-weight: bold;
  color: #e64340;
  font-size: 32rpx;
}

/* 评定结果样式 */
.result-value.severity {
  font-weight: bold;
  color: #1aad19;
}

/* 无数据提示 */
.no-data {
  text-align: center;
  padding: 80rpx 40rpx;
}

.no-data-text {
  font-size: 32rpx;
  color: #666;
  display: block;
  margin-bottom: 40rpx;
}

/* 立即填写按钮 */
.start-btn {
  background-color: #1aad19;
  color: #fff;
  font-size: 32rpx;
  width: 80%;
  margin: 0 auto;
}

/* 没有历史记录提示 */
.no-history-hint {
  text-align: center;
  padding: 60rpx 40rpx;
  margin-top: 20rpx;
}

.no-history-hint .hint-text {
  font-size: 28rpx;
  color: #999;
  font-style: italic;
}

/* 筛选无结果提示 */
.no-filter-result {
  text-align: center;
  padding: 100rpx 40rpx;
  background: #fff;
  border-radius: 20rpx;
  margin: 20rpx 0;
}

.hint-icon {
  font-size: 80rpx;
  display: block;
  margin-bottom: 20rpx;
  opacity: 0.5;
}

.no-filter-result .hint-text {
  font-size: 30rpx;
  color: #666;
  display: block;
  margin-bottom: 40rpx;
}

.reset-filter-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  font-size: 28rpx;
  border-radius: 30rpx;
  padding: 0 40rpx;
  height: 72rpx;
  line-height: 72rpx;
  width: 60%;
  margin: 0 auto;
}

.reset-filter-btn::after {
  border: none;
}

/* 量表标签 */
.scale-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10rpx;
}
.scale-tag {
  background-color: #f0f0f0;
  border-radius: 15rpx;
  padding: 8rpx 20rpx;
  font-size: 26rpx;
  color: #666;
}

/* 为了确保内容不被底部导航栏遮挡 */
.user-list {
  margin-bottom: 20rpx;
}
.no-data {
  margin-bottom: 20rpx;
}
</style>